<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Vue入门</title>
		<script src="../js/vue.js"></script>
	</head>
	<body>
		<div id="app">
		  用户名<input type="text" v-model="username" /><br>
		  密码<input type="password" v-model="password" /><br>
		  <input :disabled="isDisabled" type="button" value="登录">
		  <hr>
		  进度条:{{time}}%
		  <button @click="start" type="button">开始</button>
		</div>
		
		<script>
		Vue.config.productionTip = false
		var vm = new Vue({
		  el: '#app',
		  data: {
		    username:'',
			password:'',
			isDisabled:true,
			time:0,
			int:null
		  },
		  methods:{
			  start(){
				  this.time = 0
				  _this= this
				  this.int = setInterval(function(){
					  _this.time += 1
				  },50)
			  },
			  checkUser(){
				  if(this.username!='' && this.password!=''){
					  this.isDisabled = false
				  }else{
					  this.isDisabled = true
				  }
			  }
		  },
		  watch:{
			  username(){
				  this.checkUser()
			  },
			  password(){
				  this.checkUser()
			  },
			  time(){
				  if(this.time == 100){
					  clearInterval(this.int)
				  }
			  }
		  }
		})
		</script>
	</body>
</html>
